package variables

import "fmt"

/****************************************************************
变量声明
******************************************************************/

func DefineVar() {
	var v1 int
	var v2 string
	var v3 [10]int // Array 数组
	var v4 []int   //数组切片
	var v5 struct {
		f int
	}
	var v6 *int           // Point  指针
	var v7 map[string]int //字典, key为string类型，value为int类型
	var v8 func(a int)    // 函数类型

	//以下只是演示和变量声明无关

	v1 = 10
	fmt.Println("v1:", v1)
	v2 = "Hello, world!"
	fmt.Println("v2:", v2)
	v3 = [10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
	fmt.Println("v3:", v3)
	v4 = []int{1, 2, 3}
	fmt.Println("v4:", v4)
	v5.f = 10
	fmt.Println("v5.f:", v5.f)
	v6 = &v1
	fmt.Println("v6:", v6)
	v7 = make(map[string]int)
	v7["collin"] = 40
	fmt.Println("v7:", v7)
	v8 = A
	v8(10)
}

func A(a int) {
	fmt.Println("v8:", a)
}

func DefineVars() {
	var (
		v1 int
		v2 string
	)

	v1 = 10
	v2 = "abcdefghijklmnopqrstuvw"
	fmt.Println("v1, v2:", v1, v2)
}
